﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Billing.WindowsBase;
using Billing.Windows.Shell.SystemObjects;
using System.Globalization;
using Billing.DataObjects;

namespace Billing.Windows.Shell
{
    static class Program
    {
        public static bool IsAuthorized = false;
        public static bool IsFirstLogin = false;

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            CultureInfo oldCulture = Application.CurrentCulture;

            CultureInfo kaGECulture = new CultureInfo("ka-GE");
            kaGECulture.NumberFormat.NumberDecimalSeparator = ".";
            kaGECulture.NumberFormat.NumberGroupSeparator = ",";
            kaGECulture.NumberFormat.CurrencyDecimalSeparator = ".";
            kaGECulture.NumberFormat.CurrencyGroupSeparator = ",";
            kaGECulture.NumberFormat.CurrencySymbol = "ლარი";

            Application.CurrentCulture = kaGECulture;

            UserRightsManager.UserRightsLoader = new UserRightsLoaderImp();

            do
            {
                System.Windows.Forms.Application.Run(new LogInForm());

                if (IsAuthorized)
                {
                    KeyboardSwitcher.SwitchKeyboardLayoutToKA(true);

                    Application.Run(new FormManager(new MainForm()));

                    KeyboardSwitcher.SwitchKeyboardLayoutToCulture(oldCulture.Name, true);
                }
            }
            while (IsAuthorized);

        }
    }
}
